#ifndef _KOZOS_H_INCLUDED_
#define _KOZOS_H_INCLUDED_

#include "defines.h"
#include "syscall.h"
#include "interrupt.h"

kz_thread_id_t kz_run(kz_func_t func, char *name, int priority,
                        unsigned stacksize, int argc, char *argv[]);
void kz_exit(void);
int kz_wait(uint32 tick);
int kz_sleep(void);
int kz_wakeup(kz_thread_id_t id);
kz_thread_id_t kz_getid(void);
int kz_chpri(int priority);
void *kz_kmalloc(int size);
int kz_kmfree(void *p);
int kz_send(kz_msgbox_id_t id, int size, char *p, int priority);
kz_thread_id_t kz_recv(kz_msgbox_id_t id, int *sizep, char **pp);
kz_thread_id_t kz_recva(kz_msgbox_id_t id, int *sizep, char **pp, uint32 tick);
int kz_setintr(softvec_type_t type, kz_handler_t handler);
kz_thread_info_t *kz_getthreads(int *sizep);
kz_msgbox_id_t kz_getmsgbox(void);
int kz_freemsgbox(kz_msgbox_id_t id);
int kz_resource();
uint32 kz_systime();

void ky_start(kz_func_t func, char *name, int priority, unsigned stacksize, int argc, char *argv[]);
void ky_sysdown(const char *message);
void ky_syscall(kz_syscall_type_t type, kz_syscall_param_t *param);
void ky_softerr();
void ky_reset(void);

#ifdef NOASSERT
#define ASSERT(cond, msg)
#else
#define ASSERT(cond, msg)  do { if (!(cond)) ky_sysdown(msg); } while (0)
#endif

#endif
